$(function(){
	var parameter='';
	var p ={p:null}
	//查询所有的电影种类
	  $.ajax({
	    	type:"POST",
	    	url:"/movie.front/categoryConntroller/findAllCategory",
	    	dataType:"json",
	    	data:JSON.stringify(p),
	    	contentType : "application/json",
	    	success:function(data){
	    		var arr = data.result;
	    		for(var i=0;i<arr.length;i++){
	    			var html = '<li  style="float:left;list-style:none;width:80px" heigth="80px"><a href="#" style="text-decoration:none;"  onclick="dd('+arr[i].id+')" > <font color="black" size="3px">'+arr[i].movieCategory+'</font></a></li>';
	    		    $('.category-movies ul').append(html);
	    		}
	    	  }
	      });
	
	  //查询所有的电影
	  var p = {movieCategoryId:""};
	  movieLists(p);
	  function movieLists(p){
	  $.ajax({
		  type:"POST",
		  url:"/movie.front/movieInfo/getAllMovieInfoList",
		  data:JSON.stringify(p),
		  dataType:"json",
		  contentType:"application/json",
		  success:function(data){
			  var arr = data.result;
			  var url='http://localhost:8080/'
			  for(var i=0;i<arr.length;i++){
				 var html ='<div class="product-grid" style="width:240px">'+
				 '<a href="single.html?id='+arr[i].id+'"><div class="more-product"></div> <div class="product-img b-link-stripe b-animate-go thickbox"><img  class="img-responsive" alt="" src='+url+arr[i].moviePicture+'><div class="b-wrapper>'+
				'</div></div></a><div class="product-info simpleCart_shelfItem">'+
					'<div class="product-info-cust prt_name">'+
					'<h4>'+arr[i].movieName+'</h4>'+								
					'<div class="clearfix" style="width:1200px"> </div>'+
				'</div>'+												
			'</div>'+
		'</div>' 
			 $('#picture-list').append(html);
			   }
			 
		    }
	   });
	  }
		$('#myCart').click(function(){
			$.ajax({
				  type:'POST',
				  url:'/movie.front/orderController/getOrderListsByUserId',
				  dataType:'json',
				  contentType:'application/json',
				 
				  success:function(data){
					
					 if(data.result[0].statusCode!=null){
						  alert(data.result[0].statusCode);
						 window.location.href="account.html";
					 }else{
						 $('#myorders-table').empty();
						 var data =data.result;
						 for(var i=0;i<data.length;i++){
							 var html='';
							 html = html+'<tr><td  align="center">'+data[i].orderName+'</td><td  align="center">'+data[i].orderPrice+'元</td><td  align="center">'+data[i].orderTime+'</td></tr>';
							 $('#myorders-table').append(html);
						 }
					 }
				  }
			});
		});

});

function dd(str){
	var p={movieCategoryId:str};
	 $('#picture-list').empty();
	 $.ajax({
		  type:"POST",
		  url:"/movie.front/movieInfo/getAllMovieInfoList",
		  data:JSON.stringify(p),
		  dataType:"json",
		  contentType:"application/json",
		  success:function(data){
			  var arr = data.result;
			  var url='http://localhost:8080/'
			  for(var i=0;i<arr.length;i++){
				 var html ='<div class="product-grid" style="width:240px">'+
				 '<a href="single.html?id="'+arr[i].id+'"><div class="more-product"></div> <div class="product-img b-link-stripe b-animate-go thickbox"><img  class="img-responsive" alt="" src='+url+arr[i].moviePicture+'><div class="b-wrapper>'+
				'</div></div></a><div class="product-info simpleCart_shelfItem">'+
					'<div class="product-info-cust prt_name">'+
					'<h4>'+arr[i].movieName+'</h4>'+								
					'<div class="clearfix" style="width:1200px"> </div>'+
				'</div>'+												
			'</div>'+
		'</div>' 
			 $('#picture-list').append(html);
			   }
			 
		    }
	   });
  };
